<script setup name="cusHeader">
import {ArrowDown} from "@element-plus/icons-vue";
import store from "@/store";
import {computed, reactive} from "vue";
let userInfo = reactive({})

userInfo =  computed(() => {
  return store.state.userInfo
})

function outLogin() {
  store.commit('outLogin')
}

function getUserInfo() {
  store.commit('getUserInfo')
}
getUserInfo()
</script>

<template>
  <div class="home_header">
    <div class="home_header_bg"></div>
    <div class="home_header_body">
      <div class="home_header_logo">
        <img src="@/assets/logo.png" alt="">
        <span>通用框架</span>
      </div>
      <div class="home_header_line">|</div>
      <div class="home_header_system_btn">
        <span class="iconfont icon-xitong1"></span>
      </div>
      <div class="home_header_userName">
        <el-dropdown>
    <span class="el-dropdown-link">
      {{ userInfo.userName }}
      <el-icon class="el-icon--right">
        <arrow-down />
      </el-icon>
    </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>个人中心</el-dropdown-item>
              <el-dropdown-item @click="outLogin()">退出</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>

  </div>
</template>

<style scoped lang="scss">
.home_header {
  width: 100%;
  position: relative;

  .home_header_bg {
    position: absolute;
    width: calc(100% - 200px);
    height: 60px;
    top: 0;
    right: 0;
    // box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  }

  .home_header_body {
    width: 100%;
    height: 61px;
    display: flex;
    display: -moz-flex;
    display: -webkit-flex;
    align-items: center;
    position: relative;
    box-sizing: border-box;
    padding-right: 160px;
    background-color: #ffffff;
    border-bottom: 1px solid #eeeeee;

    .home_header_logo {
      cursor: pointer;
      width: max-content;
      flex-basis: max-content;
      flex-shrink: 0;
      height: 60px;
      box-sizing: border-box;
      padding: 0 30px;
      display: flex;
      display: -webkit-flex;
      display: -moz-flex;
      align-items: center;
      position: relative;
      z-index: 10;

      & > img {
        width: 30px;
        height: 30px;
      }

      & > span {
        color: #a4a4a4;
        margin-left: 10px;
        font-weight: 700;
        font-size: 18px;
      }
    }

    .home_header_line {
      width: max-content;
      font-size: 14px;
      color: #a4a4a4;
      margin-right: 30px;
    }

    .home_header_system_btn {
      width: max-content;
      height: auto;
      vertical-align: middle;

      .iconfont {
        cursor: pointer;
        font-size: 22px;
        color: cornflowerblue;
        transition: color 0.5s;
        -webkit-transition: color 0.5s; /* Safari */
        box-shadow: 0 3px 12px 0 rgba(100, 149, 237, 0.2);

        &:hover {
          color: red;

        }
      }

    }

    .home_header_userName {
      width: 160px;
      height: 60px;
      position: absolute;
      display: flex;
      display: -webkit-flex;
      display: -moz-flex;
      box-sizing: border-box;
      padding-right: 30px;
      align-items: center;
      justify-content: flex-end;
      right: 0;
      top: 0;

      .el-dropdown-link {
        cursor: pointer;
        color: #a4a4a4;
        display: flex;
        align-items: center;
      }
    }
  }
}
</style>